home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / sun4c / archive / tcltk.z / tcltk / man / catn / foreach.n < prev    next >
Text File  |  1994-09-20  |  1KB  |  67 lines

  1.  
  2.  
  3.  
  4. foreach(n)            Tcl Built-In Commands
  5.  
  6.  
  7.  
  8. _________________________________________________________________
  9.  
  10. NAME
  11.      foreach - Iterate over all elements in a list
  12.  
  13. SYNOPSIS
  14.      foreach _v_a_r_n_a_m_e _l_i_s_t _b_o_d_y
  15. _________________________________________________________________
  16.  
  17.  
  18. DESCRIPTION
  19.      In this command _v_a_r_n_a_m_e is the name of a variable, _l_i_s_t is a
  20.      list  of  values  to  assign  to  _v_a_r_n_a_m_e, and _b_o_d_y is a Tcl
  21.      script.  For each element of _l_i_s_t (in  order  from  left  to
  22.      right), foreach assigns the contents of the field to _v_a_r_n_a_m_e
  23.      as if the lindex command had been used to extract the field,
  24.      then  calls  the Tcl interpreter to execute _b_o_d_y.  The break
  25.      and continue statements may be invoked inside _b_o_d_y, with the
  26.      same effect as in the for command.  Foreach returns an empty
  27.      string.
  28.  
  29.  
  30. KEYWORDS
  31.      foreach, iteration, list, looping
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63. Tcl                                                             1
  64.  
  65.  
  66.  
  67.